// KnowledgeClassServiceImpl.java
package com.example.gymlearning.service.impl;

import com.example.gymlearning.entity.KnowledgeClass;
import com.example.gymlearning.mapper.KnowledgeClassMapper; // 修正导入
import com.example.gymlearning.service.KnowledgeClassService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("knowledgeClassService")
public class KnowledgeClassServiceImpl implements KnowledgeClassService {

    @Resource
    private KnowledgeClassMapper knowledgeClassMapper; // 修正为正确的Mapper

    @Override
    public List<KnowledgeClass> getAllClasses() {
        return knowledgeClassMapper.queryAll(); // 需要添加这个方法
    }

    @Override
    public KnowledgeClass getClassById(Long id) {
        return knowledgeClassMapper.queryById(id);
    }

    @Override
    public Page<KnowledgeClass> getClassesWithPagination(int page, int size) {
        PageHelper.startPage(page, size);
        List<KnowledgeClass> classes = knowledgeClassMapper.selectAll();
        return (Page<KnowledgeClass>) classes;
    }
}